public class ThreadDemo3 {
    static Object locker = new Object();
    public static void main(String[] args) throws InterruptedException {
        Thread t1 = new Thread(()->{
                synchronized (locker) {
                    System.out.println("t1执行");
                    try {
                        locker.wait();
                    } catch (InterruptedException e) {
                        throw new RuntimeException(e);
                    }
                    System.out.println("t1结束");
                }
        });

        Thread t2 = new Thread(()->{
                synchronized (locker) {
                    System.out.println("t2执行");
                    try {
                        locker.wait();
                    } catch (InterruptedException e) {
                        throw new RuntimeException(e);
                    }
                    System.out.println("t2结束");
                }
        });
        Thread t3 = new Thread(()->{
            synchronized (locker) {
                locker.notifyAll();
            }
        });
        t1.start();
        t2.start();
        Thread.sleep(1000);
        t3.start();
    }
}
